<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>

<body>
<?php
/* 新闻信息修改处理页 */
require_once("../../conn/conn_db.php");   //包含数据库连接文件
if( $_POST["txt_title"]!="" && $_POST["txt_id"]!="" )  //判断新闻标题和编号
{
    $nid = $_POST["txt_id"];           //新闻编号
    $ntid = $_POST["txt_parentid"];    //所属类别编号
    $title = $_POST["txt_title"];      //新闻标题
    $intro = $_POST["txt_intro"];      //摘要
    $contents = $_POST["txt_contents"];//内容
    $createtime = date('Y-m-d'); //发布日期
    
    $sql = "update news_info set nt_id=$ntid,n_name='$title',n_intro='$intro',n_contents='$contents',n_createtime='$createtime' where n_id=".$nid;
    $update = $conn->query($sql); //执行SQL语句
    if($update)                  //判断执行结果
    {
        echo "<script>alert('新闻信息修改成功！');self.location='../news_manager.php'</script>";
    }
    else
    {
        echo "<script>alert('新闻信息修改失败！');self.location='../news_update.php?n_id=".$nid."'</script>";
    }
}
else
{
    echo "<script>alert('所属类别和新闻标题不能为空！');self.location='../news_update.php?n_id=".$nid."'</script>";
}
?>
</body>
</html>